<?php

/**
 * WeEngine Api System
 *
 * (c) We7Team 2019 <https://www.w7.cc>
 *
 * This is not a free software
 * Using it under the license terms
 * visited https://www.w7.cc for more details
 */

namespace W7\Sdk\VSCode\Tests;

use W7\Sdk\VSCode\Traits\StorageTrait;

/**
 * fs write file
 */
class TestFileWrite extends TestCase {
	use StorageTrait;

	/**
	 * @var string
	 */
	private $route = '';
	/**
	 * @var string
	 */
	private $txtFrom = 'from.txt';
	/**
	 * @var string
	 */
	private $content = 'hello123456';

	protected function setUp(): void {
		parent::setUp(); // TODO: Change the autogenerated stub
		$this->route = route('vs.code.write.file');
	}

	/**
	 * write file
	 */
	public function testFileWrite() {
//	   var_dump(config('filesystems'));
		$this->storageDeleteFile($this->txtFrom);

		$this->postJson($this->route, [
			'uri' => $this->txtFrom,
			'content' => $this->content
		])->assertOk();
		$this->assertTrue($this->storageIsExists($this->txtFrom));
		$content = $this->storageGetContent($this->txtFrom);

		$this->assertEquals($content, $this->content);
	}
}
